﻿CREATE PROCEDURE [util].[GetOperatorXml]

AS
BEGIN
	SELECT
		1 AS [Tag]
		,NULL AS [Parent]
		,NULL AS [Root!1!]
		,NULL AS [Operator!2!Name]
		,NULL AS [Operator!2!Enabled]
		,NULL AS [Operator!2!EmailAddress]
		,NULL AS [Operator!2!PagerAddress]
		,NULL AS [Operator!2!WeekDayPagerStartTime]
		,NULL AS [Operator!2!WeekDayPagerEndTime]
		,NULL AS [Operator!2!SaturdayPagerStartTime]
		,NULL AS [Operator!2!SaturdayPagerEndTime]
		,NULL AS [Operator!2!SundayPagerStartTime]
		,NULL AS [Operator!2!SundayPagerEndTime]
		,NULL AS [Operator!2!PagerDays]
		,NULL AS [Operator!2!NetsendAddress]

	UNION ALL
	SELECT
		2 ,1 ,NULL
		,[name] AS [Operator!1!Name]
		,[enabled] AS [Operator!1!Enabled]
		,[email_address] AS [Operator!2!EmailAddress]
		,[pager_address] AS [Operator!2!PagerAddress]
		,[weekday_pager_start_time] AS [Operator!2!WeekDayPagerStartTime]
		,[weekday_pager_end_time] AS [Operator!2!WeekDayPagerEndTime]
		,[saturday_pager_start_time] AS [Operator!2!SaturdayPagerStartTime]
		,[saturday_pager_end_time] AS [Operator!2!SaturdayPagerEndTime]
		,[sunday_pager_start_time] AS [Operator!2!SundayPagerStartTime]
		,[sunday_pager_end_time] AS [Operator!2!SundayPagerEndTime]
		,[pager_days] AS [Operator!2!PagerDays]
		,[netsend_address] AS [Operator!2!NetsendAddress]
	FROM msdb.dbo.sysoperators

	ORDER BY [Operator!2!Name], [Tag], [Parent]
	FOR XML EXPLICIT

	RETURN(@@ERROR)
END